import http from "@/api";
import { Company, Post, Site, Device, DeviceType, LevelType, Staff, Tran } from "@/api/interface/province/organizationManage";

// 公司模块
// 公司列表查询接口
export const getCompanyListAPI = (data: Company.CompanySearchForm) => {
  return http.post<Company.CompanyList[]>("/manager/companyList", data, { loading: false });
};
// 公司添加接口
export const addCompanyAPI = (data: Company.CompanyAdd) => {
  return http.post("/manager/addCompany", data, { loading: false });
};
// 公司修改接口
export const upadateCompanyAPI = (data: Company.CompanyAdd) => {
  return http.post("/manager/editCompany", data, { loading: false });
};
// 公司查看详情接口
export const CompanyDetailAPI = (companyId: number) => {
  return http.get<Company.CompanyAdd>(`/manager/companyDetail/${companyId}`);
};
// 公司删除接口
export const CompanyDeleteAPI = (companyId: number) => {
  return http.delete(`/manager/deleteCompany/${companyId}`);
};
//重置管理员密码
export const restPwdAPI = (params: { companyId: number }) => {
  return http.post(`/manager/resetPassword`, { params });
};

// 岗位模块
// 岗位列表查询接口
export const getPostListAPI = (params: Post.PostSearchForm) => {
  return http.get<Post.PostList[]>("/manager/postList", params, { loading: false });
};
// 岗位添加接口
export const addPostAPI = (data: Post.PostAdd) => {
  return http.post("/manager/addPost", data, { loading: false });
};
// 岗位修改接口
export const updatePostAPI = (data: Post.PostAdd) => {
  return http.post("/manager/editPost", data, { loading: false });
};
// 岗位查看详情接口
export const postDetailAPI = (id: number) => {
  return http.get<Post.PostDetail>(`/manager/detailPost/${id}`, { loading: false });
};
// 岗位删除接口
export const postDeleteAPI = (id: number) => {
  return http.delete(`/manager/deletePost/${id}`, { loading: false });
};
// 根据公司类型查询菜单
export const getMenuListAPI = (params: { companyType: number }) => {
  return http.get<Post.MenuList[]>(`/manager/menu/listByCompanyType`, params);
};

// 设施模块
// 列表
export const getDeviceListAPI = (params: Device.DeviceSearchForm) => {
  return http.get<Device.DeviceList[]>("/manager/warehouse/facilityList", params, { loading: false });
};
// 添加接口
export const addDeviceAPI = (data: Device.AddDevice) => {
  return http.post("/manager/warehouse/addFacility", data);
};
// 修改接口
export const updateDeviceAPI = (data: Device.AddDevice) => {
  return http.post("/manager/warehouse/editFacility", data);
};
// 查看详情接口
export const deviceDetailAPI = (id: string) => {
  return http.get<Device.AddDevice>(`/manager/warehouse/facilityDetail/${id}`, { loading: false });
};
// 删除接口
export const deviceDeleteAPI = (id: string) => {
  return http.delete(`/manager/warehouse/deleteFacility/${id}`, { loading: false });
};

// 仓站模块
// 列表
export const getSiteListAPI = (params: Site.siteSearchForm) => {
  return http.get<Site.SiteList[]>("/manager/warehouseList", params, { loading: false });
};
// 仓站添加接口
export const addSiteAPI = (data: Site.SiteAddParams) => {
  return http.post("/manager/addWarehouse", data, { loading: false });
};
// 仓站修改接口
export const updateSiteAPI = (data: Site.SiteAddParams) => {
  return http.post("/manager/editWarehouse", data, { loading: false });
};
// 驿站查看详情接口
export const siteDetailAPI = (id: string) => {
  return http.get<Site.SiteAddParams>(`/manager/warehouseDetail/${id}`, { loading: false });
};
// 仓站详情查看接口
export const tranSiteDetailAPI = (id: string) => {
  return http.get<Tran.tranSiteDetail>(`/manager/transitWarehouse/${id}`, { loading: false });
};
// 仓站删除接口
export const siteDeleteAPI = (id: string) => {
  return http.delete(`/manager/deleteWarehouse/${id}`, { loading: false });
};

// 设施类型
// 列表
export const getDeviceTypeListAPI = (params: { userId: number; id: string }) => {
  return http.get<DeviceType.Data>("/manager/warehouse/facilityType", { ...params });
};
// 添加接口
export const addDeviceTypeAPI = (data: DeviceType.AddDeviceType) => {
  return http.post("/manager/warehouse/addFacilityType", data, { loading: false });
};
// 修改接口
export const updateDeviceTypeAPI = (data: DeviceType.UpdateDeviceType) => {
  return http.post("/manager/editWarehouse", data, { loading: false });
};
// 查看详情接口
export const deviceTypeDetailAPI = (id: number) => {
  return http.get<DeviceType.CentralWarehouse>(`/manager/warehouse/detailFacilityType/${id}`, { loading: false });
};
// 删除接口
export const deviceTypeDeleteAPI = (id: string) => {
  return http.delete(`/manager/warehouse/deleteFacilityType/${id}`, { loading: false });
};

// 等级类型
// 列表
export const getLevelTypeListAPI = (params: LevelType.AddLevelType) => {
  return http.get<LevelType.Data>("/manager/warehouse/levelList", { ...params });
};
// 添加接口
export const addLevelTypeAPI = (data: LevelType.AddLevelType) => {
  return http.post("/manager/warehouse/addLevel", data);
};
// 修改接口
export const updateLevelTypeAPI = (data: LevelType.UpdateLevelType) => {
  return http.post("/manager/warehouse/editLevel", data, { loading: false });
};
// 查看详情接口
export const levelTypeDetailAPI = (id: number) => {
  return http.get<LevelType.CentralWarehouse>(`/manager/warehouse/detailLevel/${id}`, { loading: false });
};
// 删除接口
export const levelTypeDeleteAPI = (id: number) => {
  return http.delete(`/manager/warehouse/deleteLevel/${id}`, { loading: false });
};

// 员工管理
// 列表
export const getStaffListAPI = (params: Staff.Search) => {
  return http.get<Staff.Row[]>("/manager/userList", params, { loading: false });
};
// 添加接口
export const addStaffAPI = (data: Staff.Add) => {
  return http.post("/manager/user", data, { loading: false });
};
// 修改接口
export const updateStaffAPI = (data: Staff.Add) => {
  return http.put("/manager/editStaff", data);
};
// 查看详情接口
export const staffDetailAPI = (userId: number) => {
  return http.get<Staff.Add>(`/manager/detailUser/${userId}`);
};
// 删除接口
export const staffDeleteAPI = (ids: string) => {
  return http.delete(`/manager/user/${ids}`, { loading: false });
};

// 根据岗位查询关联菜单
export const getStaffMenuListAPI = (params: { roleId: number }) => {
  return http.get<Staff.Row>(`/manager/menu/list`, params, { loading: false });
};

// 修改手机号接口
export const updatePhoneAPI = (data: Staff.UpdatePhone) => {
  return http.post(`/manager/users/updatePhoneNo`, data, { loading: false });
};
